package com.ruoyi.project.system.front;

import com.ruoyi.framework.shiro.service.RegisterService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.config.service.IConfigService;
import com.ruoyi.project.system.files.domain.VodFiles;
import com.ruoyi.project.system.files.service.IVodFilesService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 注册验证
 * 
 * @author ruoyi
 */
@Controller
@RequestMapping("/front")
public class FrontIndexController extends BaseController

{
    @Value("${ruoyi.profile}")
    private String profile;

    @Autowired
    private RegisterService registerService;

    @Autowired
    private IConfigService configService;

    @Autowired
    private IVodFilesService vodFilesService;

    @GetMapping("/index")
    public String register(ModelMap mmap)
    {
         List<VodFiles> list = vodFilesService.selectVodFilesList(new VodFiles());
         mmap.put("list",list);

        return "front/index";
    }

    @GetMapping("/show/{id}")
    public String show(@PathVariable("id") Long id, ModelMap mmap)
    {
        VodFiles vodFiles = vodFilesService.selectVodFilesById(id);
        String url = vodFiles.getFileUrl();
        int startIndex = url.indexOf('/', url.indexOf("//") + 2);
        String filePath= url.substring(startIndex);
        System.out.println(filePath);
        mmap.put("vodFiles", vodFiles);
        return  "front/show";
    }




}
